

import Controller from 'Controller';
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
import { GLTF } from "three/examples/jsm/loaders/GLTFLoader";

/** gltf 加载器 */
const loader = new GLTFLoader().setDRACOLoader(new DRACOLoader().setDecoderPath('./examples/js/libs/draco/gltf/'));

/** 加载一个 GLTF 模型 */
export default function getGLTFLoader(url: string, onProgress?: (event: ProgressEvent) => void) {
    return new Promise<GLTF>((resolve, reject) => {
        loader
            .setRequestHeader({ 'ldteProjectPath': Controller.instance.state.project.path || '' })
            .load(url, resolve, onProgress, reject);
    })
}


